﻿<sap:ActivityDesigner x:Class="ReadKeyActivityDesigner"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="clr-namespace:System;assembly=mscorlib"
    xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
    xmlns:sapc="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation"
    xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation">

    <sap:ActivityDesigner.Icon>
        <DrawingBrush >
            <DrawingBrush.Drawing>
                <ImageDrawing ImageSource="{Binding Source={StaticResource ActIcoReadKey}}">
                    <ImageDrawing.Rect>
                        <Rect Location="0,0" Size="16,16" ></Rect>
                    </ImageDrawing.Rect>
                </ImageDrawing>
            </DrawingBrush.Drawing>
        </DrawingBrush>
    </sap:ActivityDesigner.Icon>

    <sap:ActivityDesigner.Resources>
        <sapc:ArgumentToExpressionConverter x:Key="ArgumentToExpressionConverter" />

        <DataTemplate x:Key="ExpandedActivityViewTemplate">
            <Border BorderThickness ="1">
                <Grid >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Label Grid.Column="0" Grid.Row="1" Content="{Binding Source={StaticResource ActRKArgumentName}}" />
                    <sapv:ExpressionTextBox Grid.Column="1" 
                                            Width="200"
                                            Expression="{Binding ModelItem.InputKey, Mode=TwoWay, Converter={StaticResource ArgumentToExpressionConverter}, ConverterParameter=Out}"
                                            ExpressionType="s:String"
                                            OwnerActivity="{Binding Path=ModelItem}"
                                            UseLocationExpression="True" />
                </Grid>
            </Border>
        </DataTemplate>

        <DataTemplate x:Key="CollapsedActivityViewTemplate">
            <Label Padding="0,0,0,0" FontStyle="Italic"
                       Foreground="{x:Static SystemColors.GrayTextBrush}" HorizontalAlignment="Center"
                       VerticalAlignment="Center" Content="{Binding Source={StaticResource ActRKDoubleClick}}"></Label>
        </DataTemplate>

        <Style x:Key="ConnectionSettingsStyle" TargetType="{x:Type ContentPresenter}">
            <Setter Property="ContentTemplate" Value="{DynamicResource CollapsedActivityViewTemplate}" />
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=ShowExpanded}" Value="true">
                    <Setter Property="ContentTemplate" Value="{DynamicResource ExpandedActivityViewTemplate}" />
                </DataTrigger>
            </Style.Triggers>
        </Style>

    </sap:ActivityDesigner.Resources>

    <ContentPresenter Style="{DynamicResource ConnectionSettingsStyle}" Content="{Binding}" />

</sap:ActivityDesigner>

